﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace Convertor.Plugin.InsertText
{
    class EndConvertor : IValueConverter
    {
        #region IValueConverter 成员

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Visibility r;
            int b = int.Parse((string)parameter); //0:Offset 1:Length 2:CombineTextBox
            InsertTypes type = (InsertTypes)value;
            switch (type)
            {
                default:
                case InsertTypes.Move:
                    if (b == 0)
                    {
                        r = Visibility.Visible;
                    }
                    else
                    {
                        r = Visibility.Collapsed;
                    }
                    break;
                case InsertTypes.Insert:
                    if (b == 2)
                    {
                        r = Visibility.Visible;
                    }
                    else
                    {
                        r = Visibility.Collapsed;
                    }
                    break;
                case InsertTypes.Delete:
                    if (b == 1)
                    {
                        r = Visibility.Visible;
                    }
                    else
                    {
                        r = Visibility.Collapsed;
                    }
                    break;
            }
            return r;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
